import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 三石
 * Date: 2022-04-23
 * Time: 23:34
 */
public class work {


    /**
     * 求1-100中9出现的个数
     * @param args
     */
    public static void main(String[] args) {
        int count=0;
        for (int i = 1; i <=100 ; i++) {
            if(i%10==9||i/10==9){
                count++;
                System.out.print(i);
                System.out.print("  ");
                if (count%5==0){
                    System.out.print("\n");
                }
            }
        }
        System.out.println();
        System.out.println("1-100之间，9的个数为：");
        System.out.println(count);
    }



    /**
     * 判断是不是素数
     * @param n
     * @return
     */
    public static int Prime(int n){
        int x=1;
        for (int j = 2; j <n ; j++) {
            if(n%j==0){
                x=0;
                break;
            }
        }
        return x;
    }
    public static void main9(String[] args) {
        System.out.println("请输入n的值");
        Scanner scan=new Scanner(System.in);
        int n= scan.nextInt();
        int m=Prime(n);
        if(m==1){
            System.out.println("n是素数");
        }else{
            System.out.println("n不是素数");
        }
    }



    /**
     * 求1-100之间的所有素数
     * @param
     */
    public static int fun3(int n){
        int x=1;
        for (int j = 2; j <n ; j++) {
            if(n%j==0){
                x=0;
                break;
            }
        }
        return x;
    }

    public static void main8(String[] args) {
        System.out.println("1-100之间所有素数为：");
        int count=0;
        for (int i = 2; i <= 100 ; i++) {
            int a=fun3(i);
            if(a==1){
                System.out.printf("%2d",i);
                System.out.print("  ");
                count++;
                if(count%5==0){
                    System.out.print("\n");
                }
            }
        }
    }

    /**
     * 判断闰年
     * @param n
     * @return
     */
    public static int prime(int n){
        if((n%400==0)||(n%100!=0&&n%4==0)){
            return 1;
        }else {
            return 0;
        }
    }
    public static void main7(String[] args) {
        System.out.println("1000-2000年闰年列表如下：");
        int count=0;
        for (int n = 1000; n <=2000 ; n++) {
            int a=prime(n);
            if(a==1){
                System.out.print(n);
                System.out.print("  ");
                count++;
                if(count%15==0){
                    System.out.print("\n");
                }
            }

        }
    }

    /**
     * 输出两个数的最大公约数
     * @param args
     */
    public static void main6(String[] args) {
        Scanner scan=new Scanner(System.in);
        System.out.println("请输入第一个数");
        int n= scan.nextInt();
        System.out.println("请输入第二个数");
        int m= scan.nextInt();
        if(n>m){
            int temp=n;
            n=m;
            m=temp;
        }
        for (int i = n; i >=0 ; i--) {
            if (n%i==0&&m%i==0){
                System.out.println("最大公约数是：");
                System.out.println(i);
                break;
            }
        }
    }
    /**
     * 水仙花数
     * @param n
     * @return
     */
    public static int fun2(int n){  //fun2用来计算3次方
        int ret=1;
        for (int j = 1; j <=3 ; j++) {
            ret*=n;
        }
        return ret;
    }
    public static int fun(int i){ //fun用来分解数字，如153分解成1，5，3.再一个个计算3次方
        int sum=0;
        while (i!=0){
            int a=i%10;
            int b=fun2(a);
            i=i/10;
            sum+=b;
        }
        return sum; //返回分解后的数字的3次方之和
    }
    public static void main5(String[] args) {
        for (int i = 0; i <=999; i++) {
            int x=fun(i); //判断返回值和i是否相等
            if(x==i){
                System.out.println(i);
            }
        }
    }
    public static void main4(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (i == j || j == n -i-1) {
                        System.out.print("*");
                    } else {
                        System.out.print(" ");
                    }

                }
                System.out.println("\n");
            }
        }
    }

    public static void main3(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int n = in.nextInt();
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++) {
                    if (i == j || j == n - i - 1) {
                        System.out.print("*");
                    } else {
                        System.out.print(" ");
                    }
                    System.out.println("\n");
                }
            }
        }
    }


    /**
     * 输入密码
     * @param args
     */
    public static void main2(String[] args){
        int count = 3;
        int m = 123;
        System.out.println("请输入密码：");
        while (count != 0) {
            Scanner scan1 = new Scanner(System.in);
            int n = scan1.nextInt();
            if (n == m) {
                System.out.println("登录成功");
                break;
            } else {
                System.out.println("密码错误，请重新输入");
                count--;
            }
        }
    }


    /**
     * 乘法口诀表
     * @param args
     */
    public static void main1 (String[]args){
        Scanner scan2 = new Scanner(System.in);
        int n = scan2.nextByte();
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(i + "x" + j + "=" + i * j + '\t');
                if (i == j) {
                    System.out.println("\n");
                }
            }
        }
    }
}

